<?php
namespace app\middleware;
use think\facade\Db;
class AppAdmin
{
    public function handle($request, \Closure $next)
    {
        $info=$request->header();				
		if(isset($info['access-token']))		{	
			
			$userid=Db::name('login_log')->where("token",$info['access-token'])->value('userid');			
			if($userid)
			{
				$admin=Db::name('admin')->where("userid",$userid)->field("userid,roleid,username")->find();				
				$request->admin=$admin;
			}			
		}
		else{
			$request->admin=null;
		}
		
		
        
		 return $next($request);
    }
}
